package com.stylefeng.guns.gateway.modular.vo;

import lombok.Data;

import java.io.Serializable;

/**
 * @author dengwubo
 */
@Data
public class ResponseVO<M> implements Serializable {
    /**
     * 返回状态 [0-成功,1-业务失败,999-系统异常]
     **/
    private Integer status;
    /**
     * 返回信息
     **/
    private String msg;

    private String imgPre;

    private Integer nowPage;

    private Integer totalPage;

    /**
     * 返回数据实体
     **/
    private M data;

    private ResponseVO() {
    }

    public static <M> ResponseVO success(String msg) {
        ResponseVO responseVO = new ResponseVO();
        responseVO.setStatus(0);
        responseVO.setMsg(msg);
        return responseVO;
    }

    public static <M> ResponseVO success(M m) {
        ResponseVO responseVO = new ResponseVO();
        responseVO.setStatus(0);
        responseVO.setData(m);
        return responseVO;
    }

    public static <M> ResponseVO success(M m, String imgPre) {
        ResponseVO responseVO = new ResponseVO();
        responseVO.setStatus(0);
        responseVO.setData(m);
        responseVO.setImgPre(imgPre);
        return responseVO;
    }

    public static <M> ResponseVO success(M m,String imgPre, Integer nowPage,Integer totalPage) {
        ResponseVO responseVO = new ResponseVO();
        responseVO.setStatus(0);
        responseVO.setData(m);
        responseVO.setImgPre(imgPre);
        responseVO.setNowPage(nowPage);
        responseVO.setTotalPage(totalPage);
        return responseVO;
    }

    public static ResponseVO serviceFail(String msg) {
        ResponseVO responseVO = new ResponseVO();
        responseVO.setStatus(1);
        responseVO.setMsg(msg);
        return responseVO;
    }

    public static ResponseVO appFail(String msg) {
        ResponseVO responseVO = new ResponseVO();
        responseVO.setStatus(999);
        responseVO.setMsg(msg);
        return responseVO;
    }

}
